package cn.edu.zut.service;

import cn.edu.zut.dao.BookDao;
import cn.edu.zut.dao.BookTypeDao;
import cn.edu.zut.dto.BookAndType;
import cn.edu.zut.model.Book;
import cn.edu.zut.model.BookType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired(required = false)
    private BookDao bookdao;
    @Autowired(required = false)
    private BookTypeDao bookTypeDao;
    @Autowired
    Book book;

    public List<BookAndType> selectBook() {
        return bookdao.selectBook();
    }

    public List<Book> selectBookByBookid(int bookid) {
        return bookdao.selectBookByBookid(bookid);
    }

    public List<BookAndType> selectBookByISBN(String isbn) {
        return bookdao.selectBookByISBN(isbn);
    }

    public List<BookAndType> selectBookByName(String bookname) {
        return bookdao.selectBookByName(bookname);
    }

    public List<Book> selectBookByTypeid(int typeid) {
        return bookdao.selectBookByTypeid(typeid);
    }

    public List<BookAndType> selectBookAndTypeByTypeid(String typename) {
        return bookdao.selectBookAndTypeByTypeid(typename);
    }

    public List<BookAndType> selectBookByAuthor(String author) {
        return bookdao.selectBookByAuthor(author);
    }

    public List<BookAndType> selectBookByPublish(String publish) {
        return bookdao.selectBookByPublish(publish);
    }

    public boolean addBook(Book book) {
        int i = bookdao.addBook(book);
        return i>0;
    }

    public boolean deleteBook(Book book) {
        int i = bookdao.deleteBook(book);
        return i>0;
    }

    public boolean updateBook(Book book) {
        int i = bookdao.updateBook(book);
        return i>0;
    }

    public boolean updateBookStatus(Book book) {
        int i = bookdao.updateBookStatus(book);
        return i>0;
    }
}
